<template>
  <div class="home">
    <h1>This is an home page</h1>
    {{JSON.stringify(loading)}}
    {{count}} <el-button @click="update"> + 1</el-button>
    {{b}}<el-button @click="updateB">b = 'a'</el-button>
  </div>
</template>

<script>
import {mapState, mapActions} from 'vuex';
import {namespace as loading} from '@/store/libs/actions-loading';
import _ from 'lodash';

export default {
  name: 'home',
  computed: {
    ...mapState(loading, {
      loading: state => state['updateCount'] || false,
    }),
    ...mapState({
      count: state => state.count,
      b: state => _.get(state, 'b', false),
    }),
  },
  methods: {
    ...mapActions({
      updateCount: 'updateCount',
      updateStateB: 'updateStateB',
    }),
    update () {
      this.updateCount({value: this.count + 1});
    },
    updateB () {
      this.updateStateB({b: 'a'});
    }
  }
}
</script>
